<!--
 * @Author: your name
 * @Date: 2021-07-20 09:05:29
 * @LastEditTime: 2021-07-20 09:53:18
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \提高效率代码练习\ex.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        // 声明和初始化数组
        /* let array = Array(5).fill('');
        console.log(array)
        let matir=Array(5).fill(5).map(()=>Array(5).fill(5))
        console.log(matir) */
        //找总和，最大值，最小值
        /* let array = [15, 5, 6, 9, 8]
        console.log(array.reduce((a, b) => a + b))
        console.log(array.reduce((a, b) => a > b ? a : b))
        console.log(array.reduce((a, b) => a < b ? a : b)) */
        //对字符串，数组排序
        //用内置方法sort()和reverse()
        //sort()为升序,reverse()为降序
        /* let stringArr = ['a', 'b', 'd', 'c', 'z', 'h']
        console.log(stringArr.sort())
        console.log((stringArr.reverse()))
        let array = [5, 2, 15, 3, 22]
        console.log(array.sort((a, b) => a - b))
        console.log(array.reverse((a, b) => a - b))
        console.log(array.sort((a, b) => b - a)) */
        //从数组中过滤出虚假值
        let arr=[5,6,8,'',false]
        console.log(arr.filter(Boolean))




    </script>
</body>

</html>